//
//  ReportViewController.m
//  SXH
//
//  Created by 龚啸 on 15/10/21.
//  Copyright © 2015年 lyss. All rights reserved.
//

#import "ReportViewController.h"
#import "CommonService.h"

#define REPORTNUMBER 7
@interface ReportViewController ()
{
    NSString * reportType;
}
@property (weak, nonatomic) IBOutlet UIButton *btnConfirm;

@end

@implementation ReportViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _btnConfirm.userInteractionEnabled = NO;
    _btnConfirm.alpha = 0.4;
    reportType = nil;
    _btnConfirm.layer.cornerRadius = 8.0;
}
- (IBAction)doback:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)btnConfirm:(id)sender {
    [self postReport:self.userId travel_id:self.travel_id report_type:reportType];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"感谢您的举报" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
    alert.tag =3333;
    [alert show];
    
}
- (IBAction)btnChoose:(id)sender {
    _btnConfirm.userInteractionEnabled =YES;
    _btnConfirm.alpha =1;
    UIImage *selecticonNo =[UIImage imageNamed:@"未选中"];
    
    UIImage *selecticon =[UIImage imageNamed:@"选中"];
    
    UIButton *btn=nil;
    for (int i=1;i<REPORTNUMBER;i++) {
        
        btn = (UIButton *)[self.view viewWithTag:i];   //获取单选按钮  mainZone 是最外层的视图
        
        if ([btn isSelected]) {
            
            [btn setBackgroundImage:selecticonNo forState:UIControlStateNormal];
            
            [btn setSelected:NO];
            
        }
        
    }
    
    [sender setBackgroundImage:selecticon forState:UIControlStateSelected];
    
    [sender setSelected:YES];
    UIButton *btnSelected = nil;
    btnSelected = sender;
    reportType = [NSString stringWithFormat:@"%d",(int) btnSelected.tag];
    
}
-(void)postReport:(NSString *)user_id travel_id:(NSString *)travel_id report_type:(NSString *)report_type
{
    CommonService *service =[[CommonService alloc] init];
    NSDictionary *param =[NSDictionary dictionaryWithObjectsAndKeys:
                          user_id,@"user_id",
                          travel_id,@"travel_id",
                          report_type,@"report_type",nil];
    [service getNetWorkData:param Path:REPORT Successed:^(id entity) {
    } Failed:^(NSInteger errorCode, NSString *message) {
        
    }];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag == 3333) {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

@end
